<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://suryani.cn/support/tags" prefix="page"%>

<!DOCTYPE html>
<html lang="${lang}">
<head>
<title>订单管理-手机支付成功的订单列表</title>
<base href="${base }" />
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lte IE 8]>
	<script language="javascript" type="text/javascript" src="excanvas.min.js"></script>
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="less/default.less">
<script type="text/javascript" src="js/less.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.stickymenu.js"></script>
<script type="text/javascript" src="js/emm-1.0.js"></script>
<script type="text/javascript" src="js/jquery.topLink.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.flot.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript">
	var oTable=null;
	$(document).ready(function() {
		oTable=$("#orderList").dataTable({
			"oLanguage" : {
				"sUrl" : "js/i18n/table_zh.txt"
			},
			"aoColumns" : [ {
				"mDataProp":"id",
				"sWidth" : "8%",
				"bUseRendered": false,
				"fnRender" : function(obj){
					return "<a href='order/view?orderId="+obj.aData.id+"'>"+obj.aData.id+"</a>"; 
				}
			},{
				"mDataProp":"orderCode",
				"sWidth" : "10%"
			},{
				"mDataProp":"user",
				"sWidth" : "10%",
				"fnRender" : function(obj){
					return obj.aData.user.username;
				}
			}, {
				"mDataProp":"shipAddress",
				"sWidth" : "15%",
				"fnRender" : function(obj){
					if(obj.aData.shipAddress == null)
						return "无";
					else
						return obj.aData.shipAddress.address;
				}
			}, {
				"mDataProp":"storeName",
				"sWidth" : "10%"
			}, {
				"mDataProp":"totalPrice",
				"sWidth" : "10%"
			}, {
				"mDataProp":"postCost",
				"sWidth" : "10%"
			}, {
				"mDataProp":"storeId",
				"sWidth" : "10%",
				"fnRender" : function(obj) {
					return "<div class='btn-group'><a class='btn delete' data-id="+obj.aData.id+" >删除</a></div>";
				}
			} ],


			"bPaginate" : true,
			"sPaginationType" : 'full_numbers',
			"aLengthMenu": [[5,10,15,20,30], [5,10,15,20,30]],
			"bFilter" : false,
			"bSort" : false,
			"bServerSide": true,        
			"sScrollX": "960px",        
			"fnServerData": function ( sSource, aoData, fnCallback ) {
				var data = {};
				$("#searchForm")
				.find("input[type='text'], select option:selected")
				.each(function() {
					data[ this.name || this.parentNode.name] = this.value;
				});
				
				var aoDataMap = toAoDataMap(aoData);
				data.offset = aoDataMap.iDisplayStart; 
				data.fetchSize = aoDataMap.iDisplayLength;
	 			$.ajax({
	             "dataType": 'json', 
	             "type": "POST", 
	             "url": "order/list", 
	             "data": data, 
	             "success": function(data){
	             	var aoData = {
	             		iDisplayStart: data.offset,
	             		iDisplayLength: data.fetchSize,
	             		aaData: data.data,
	             		iTotalDisplayRecords: data.total,
	             		iTotalRecords: data.total
	             	};
	             	fnCallback(aoData);
	             }
	         	});
         	}
		});

		$('#top-link').topLink({
			min : 400,
			fadeSpeed : 500
		});
		
		$("#searchForm").submit(function(e){
			oTable.fnPageChange( 'first' );
			return false;
		});
	});
	
	$("#orderList .delete").live("click",function(e) {
		var id = $(e.target).attr("data-id");
		if (!confirm("你确定要删除ID为[" + id+ "]的订单吗?")) {
			return "";
		}
		$.ajax({
			type : 'POST',
			url : "order/delete?id=" + id,
			data : "",
			success : function(returnMessage) {
				if (returnMessage == "true") {
					var ipage = getDateTablePageInfo(oTable
							.fnSettings()).iPage;
					oTable.fnPageChange(ipage);
				} else {
				}
			}
		});
	});
	
</script>
</head>
<body>
	<div class="page">
		<page:view page="/common/left?menu=order" />
		<div id="main" class="main container">
			<page:view page="/common/header?parentTitle=订单查询&childTitle=手机支付成功的订单列表" />
			<div id="menu" class="row-fluid menu">
				<form class="form-search" id="searchForm">
					<input type="text" name="queryParam" id="queryParam" class="input-medium search-query"
						placeholder="请输入订单号或商铺名"> 
						<span class="block">
							<div class="btn-group">
								<input type="submit" class="btn btn-primary" value="搜索">
							</div>
						</span>
				</form>
			</div>
			<div class="row-fluid">
				<div class="widget">
					<div class="inner">
						<table id="orderList">
							<thead>
								<tr>
									<th>订单ID</th>
									<th>订单编码</th>
									<th>用户名</th>
									<th>配送地址</th>
									<th>商铺名称</th>
									<th>总金额</th>
									<th>配送费</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div id="footer" class="row section footer">
				<label class="copyright">©舜亚科技 2012</label>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<a href="#top" id="top-link">回到顶部</a>
</body>
</html>